<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/js/ext/resources/css/ext-all.css"/>

    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/ext-all.js"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/ext-lang-es.js"></script>
    
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/plugins/searchfield.js"></script>
    <script type="text/javascript">
    var BASE_URL = '<?php echo base_url(); ?>' + 'index.php/';
    var BASE_PATH = '<?php echo base_url(); ?>';
    var BASE_ICONS = BASE_PATH + 'assets/icons/';
    
    Ext.onReady(function() {
        
    	 var  productos = new Ext.data.Store({
    		    reader: new Ext.data.JsonReader({
    		        fields: ['idProducto', 'producto'],
    		        root: 'rows'
    		    }),
    		    proxy: new Ext.data.HttpProxy({
    		    	 url: BASE_URL + 'producto/productoSelect',
    	                method: 'POST'
    		    })
    		}); 
 		

        Ext.QuickTips.init();//muestra mensaje en campos obligatorios
        Ext.form.Field.prototype.msgTarget = 'side';  
    
        var formProducto = new Ext.form.FormPanel({
        	  xtype       : 'form',
        	  waitTitle: 'Procesando',
  			  waitMsg:'Por favor Espere...',
              standardSubmit: true,
              url:BASE_URL+'producto/stockInsert',
              method:'POST',
              loadMask: true,
              height      : 570,
              //autoScroll  : true,
              id          : 'formpanel',
              frame:true,
              title: 'Stock',
              bodyStyle:'padding-left:200px;padding-right:200px;',
              width: 1110,
              items: [{
            	  xtype:'fieldset',
                  title: 'Datos Producto',
                  collapsible: true,
                  items :[
                          {
                        	  xtype       : 'datefield',
                              fieldLabel : 'Fecha Ingreso',
                              name: 'fechaingreso',
                              anchor: '90%',
                              allowBlank: false  
                          },{
                              xtype: 'combo',  
                              triggerAction : 'all',  
                              store: ["Guia de Despacho","Factura","Orden de Compra"],
                              fieldLabel : 'Tipo Documento',
                              name: 'tipodocumento',
                              emptyText:'Seleccione tipo...',
                              anchor: '90%',
                              allowBlank: false 
                            }, {
                             	  xtype: 'numberfield',
                                  fieldLabel : 'Nro Documento',
                                  name: 'nrodocumento',
                                  allowNegative: false,
                                  allowDecimals: true,
                                  anchor: '90%',
                                  allowBlank: false 
                            },                                         
                            {
                          	  xtype: 'combo',  
                                triggerAction : 'all',  
                                fields: ['id', 'bodega'],
                                store: [['1','Santiago 1'],['2','Chiloe']],
                                fieldLabel : 'Bodega',
                                name: 'bodega',
                                emptyText:'Seleccione bodega...',
                                anchor: '90%',
                                valueField: 'id',
                                allowBlank: false  
                            },{
                	  xtype: 'combo',
                	  name: 'producto',
                	  fieldLabel: 'Producto',
                	  emptyText:'Seleccione producto...',
                	  mode: 'local',
                	  store: productos,
                	  displayField:'producto',
                      anchor: '90%',
                      allowBlank: false 
                    },{
                	  xtype       : 'numberfield',
                	  id: 'nroCajas',
                	  //value: '0',
                      fieldLabel : 'Cantidad Cajas',
                      name: 'nrocajasmaster',
                      allowNegative: false,
                      anchor: '90%',
                      allowBlank: false  
                  },{
                	  xtype       : 'numberfield',
                      fieldLabel : 'Kg/Caja',
                      name: 'kgporcaja',
                      allowNegative: false,
                      anchor: '90%',
                      allowBlank: false  
                  },{
                	  xtype       : 'textfield',
                      fieldLabel : 'Ingresado por',
                      name: 'responsable',
                      anchor: '90%',
                      allowBlank: false  
                  },{
                	  xtype       : 'textarea',
                      fieldLabel : 'Observacion',
                      name: 'observacion',
                      anchor: '90%',
                      multiline: true,
                      allowBlank: false  
                  }]
              }],
              buttons: [{
                  text: 'Guardar',
                  	handler: function() {
                  		formProducto.getForm().submit();
          		}
              },{
                  text: 'Limpiar',
                  handler: function()
                  {
                	  formProducto.getForm().reset();
                  }
               }
              ]
        });

        formProducto.render('divgrid');
        productos.load();
        
    });  
    </script>
    <style type="text/css">
        #divgrid {
            background: #e9e9e9;
            border: 1px solid #d3d3d3;            
        }
    </style>

    <title></title>
</head>
<body>
    <div id="divgrid"></div>
</body>
</html>